@extends("admin.base")
  @section("content")
		  <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            轮播图
            <small>preview of simple tables</small>
          </h1>
          <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">轮播图</a></li>
            <li class="active">轮播图浏览</li>
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">
          <div class="row">
            <div class="col-md-12">
              <div class="box">
                <div class="box-header with-border">
                  <h3 class="box-title"><i class="fa fa-th"></i> 轮播图浏览</h3>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <button class="btn btn-primary" onclick="loadAdd()">添加轮播图</button>
                </div><!-- /.box-header -->
                <div class="box-body">
                  <table class="table table-bordered">
                    <tr>
                      <th style="width:60px">ID</th>
                      <th >图片</th>
                      <th style="width:300px">url地址</th>
                      <th style="width:100px">操作</th>
                    </tr>
                   @foreach($list as $v)
                    <tr>
                      <td style="height:60px">{{$v->id}}</td>
                      <td style="height:60px"><img src="/uploads/{{$v->img}}"></td>
                      <td style="height:60px">{{$v->dzur}}</td>
                      <td style="height:60px">
                        <button onclick="doDel()" class="btn btn-xs btn-danger">删除</button> 
                          <button onclick="doUpdate({{$v->id}})" class="btn btn-xs btn-primary">编辑</button>                      
                      </td>
                    </tr>
                   @endforeach
                  </table>
                </div><!-- /.box-body -->
                
                <div class="box-footer clearfix">
                 {!! $list->render() !!}
                </div>
                 
              </div><!-- /.box -->
            </div><!-- /.col -->
            
          </div><!-- /.row -->
         
        </section><!-- /.content -->
        <form action="" style="display:none;" id="mydeleteform" method="post">
            <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
            <input type="hidden" name="_method" value="DELETE">
            <input type="hidden" name="_method" value="PUT">
        </form>
	@endsection

  @section('myscript')
    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
        <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="exampleModalLabel">New message</h4>
          </div>
          <div class="modal-body">
           <!-- 此处填充 -->
          </div>
        </div>
      </div>
    </div>
    <script type="text/javascript">
        function doDel(id){
          if(confirm("你确定删除吗？"))
            $("#mydeleteform").attr("action","{{url('admin/carousel')}}/"+id).submit();
        }

        function  loadAdd(){
            $("#exampleModalLabel").html("添加信息");
            $("#exampleModal").modal("show"); 

            $.ajax({
              url:"{{URL('admin/carousel/create')}}",
              type:"get",
              async:true,
              dataType:"html",
              success:function(data){
                  $("#exampleModal .modal-body").html(data);   
                },
            });
        }   
         function  doUpdate(id){
          $("#exampleModalLabel").html("修改信息");
          $("#exampleModal").modal("show"); 

          $.ajax({
            url:"{{url('admin/carousel')}}/"+id+"/edit",
            type:"get",
            async:true,
            dataType:"html",
            success:function(data){
              $("#exampleModal .modal-body").html(data);
            },
          });
        }
    </script>
  @endsection